<template>
	<view class="content poRel">
		<view class="" v-if="Object.keys(tech_info).length > 0 && zt">
			<view style="height: 30rpx;"></view>
			<view v-if="id" class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>姓名</view>
				<input class="foSi30" v-model="name" style="width: 65%;text-align: right;" placeholder="输入您的姓名"
					placeholder-style="color: #737373;" />
			</view>
			<view v-if="id" class="wid100 xia"></view>
			<view v-if="id" class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>性别</view>
				<view class="dis disAl" style="width: 65%;justify-content: flex-end;">
					<view class="dis disAl" @click="sax = 0">
						<view v-if="sax == 0" class="dis disAl disJuC borRad50" :style="'border: 1rpx solid '+theme.main_color+';'"
							style="width: 26rpx;height: 26rpx;">
							<view class="borRad50" :style="'background: '+theme.main_color+';'" style="width: 14rpx;height: 14rpx;"></view>
						</view>
						<view v-if="sax != 0" class="dis disAl disJuC borRad50"
							style="width: 26rpx;height: 26rpx;border: 1rpx solid #818181;"></view>
						<view class="mar-left10" :style="sax == 0?'color: '+theme.main_color+';':'color: #737373;'">男</view>
					</view>
					<view class="dis disAl mar-left30" @click="sax = 1">
						<view v-if="sax == 1" class="dis disAl disJuC borRad50" :style="'border: 1rpx solid '+theme.main_color+';'"
							style="width: 26rpx;height: 26rpx;">
							<view class="borRad50" :style="'background: '+theme.main_color+';'" style="width: 14rpx;height: 14rpx;">
							</view>
						</view>
						<view v-if="sax != 1" class="dis disAl disJuC borRad50"
							style="width: 26rpx;height: 26rpx;border: 1rpx solid #818181;"></view>
						<view class="mar-left10" :style="sax == 1?'color: '+theme.main_color+';':'color: #737373;'">女</view>
					</view>
				</view>
			</view>
			<view v-if="id" class="wid100 xia"></view>
			<view v-if="id" class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>生日</view>
				<picker mode="date" :value="birthday" @change="birthdayChange">
					<view class="dis disAl foSi30">
						<view v-if="birthday" class="mar-right10">{{birthday}}</view>
						<view v-if="!birthday" class="mar-right10" style="color: #737373;">请选择</view>
						<uni-icons type="right" size="30rpx" color="#737373"></uni-icons>
					</view>
				</picker>
			</view>
			<view v-if="id" class="wid100 xia"></view>
			<view v-if="id" class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>手机号</view>
				<input class="foSi30" v-model="phone" type="number" style="width: 65%;text-align: right;" placeholder="输入手机号"
					placeholder-style="color: #737373;" />
			</view>
			<view v-if="id" class="wid100 xia"></view>
			<view class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>从业年份</view>
				<input class="foSi30" v-model="work" style="width: 65%;text-align: right;" placeholder="输入从业年份，例如：5"
					placeholder-style="color: #737373;" />
			</view>
			<view class="wid100 xia"></view>
			<view v-if="id" class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>意向工作城市</view>
				<picker :value="cityIndex" @change="bindCityChange" :range-key="'title'" :range="addressList">
					<view class="dis disAl foSi25">
						<view class="mar-right10" :style="city?'':'color: #737373;'">{{city?city.title:'请选择'}}
						</view>
						<uni-icons type="right" size="25rpx"></uni-icons>
					</view>
				</picker>
			</view>
			<view v-if="id" class="wid100 xia"></view>
			<view v-if="city && id" class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;">挂靠门店</view>
				<picker @change="shopChange" :value="shopIndex" :range="shopList" range-key="store_name">
					<view class="dis disAl foSi30">
						<view class="mar-right10" :style="shop?'':'color: #7A7979;'">{{shop?shop.store_name:'请选择'}}
						</view>
						<uni-icons type="right" size="30rpx" color="#737373"></uni-icons>
					</view>
				</picker>
			</view>
			<view v-if="city && id" class="wid100 xia"></view>
			<view class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>所在地址</view>
				<view class="dis disAl foSi30" style="max-width: 75%;" @click="xuandian">
					<view v-if="!address" class="mar-right10" style="color: #737373;">请选择地址</view>
					<view v-if="address" class="mar-right10">{{address}}</view>
					<!-- <input class="foSi30 mar-right10" v-model="address" style="width: 65%;text-align: right;" 
				placeholder="请选择地址" placeholder-style="color: #737373;"/> -->
					<uni-icons type="location" size="30rpx" :color="theme.main_color"></uni-icons>
				</view>
			</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar">
				<view class="fowe600 foSi35 mar-top20">技师简介</view>
				<view class="mar-top20">
					<textarea class="wid95 mar foSi30" v-model="introduction" :maxlength="100" auto-height
						placeholder="输入技师简介" placeholder-style="color: #737373;" />
				</view>
				<view class="dis disAl mar-top20" style="justify-content: flex-end;">{{introduction.length}}/100
				</view>
			</view>
			<view class="wid100 xia mar-top30"></view>
			<view class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>真实姓名</view>
				<input class="foSi30" v-model="zName" style="width: 65%;text-align: right;" placeholder="输入您的真实姓名"
					placeholder-style="color: #737373;" />
			</view>
			<view class="wid100 xia mar-top30"></view>
			<view class="hei97 wid90 mar dis disAl disJuB">
				<view class="fowe600 foSi35" style="width: 35%;"><span style="color: #FF0000;">*</span>身份证号</view>
				<input class="foSi30" v-model="numberID" type="idcard" style="width: 65%;text-align: right;" placeholder="输入您的身份证号"
					placeholder-style="color: #737373;" />
			</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar">
				<view class="fowe600 foSi35 dis disAl mar-top30">
					<span style="color: #FF0000;">*</span>
					<span>身份证照片</span>
					<span class="foSi20 mar-left30" style="color: #737373;">图片大小不超过10M</span>
				</view>
				<view class="dis disAl mar-top30 wid95 mar">
					<view class="borRad20" @click="shangImage(0)"
						style="width: 190rpx;height: 175rpx;background-color: #EEEEEE;">
						<view v-if="!sImage" style="color: #737373;">
							<view style="height: 50rpx;"></view>
							<view class="mar" style="width: 44rpx;height: 36rpx;">
								<image src="../../static/shangchuan.png" class="wh100"></image>
							</view>
							<view class="textCen foSi18 mar-top15">身份证人像面</view>
						</view>
						<image v-if="sImage" :src="url+sImage" class="wh100 borRad20"></image>
					</view>
					<view class="mar-left30 borRad20" @click="shangImage(1)"
						style="width: 190rpx;height: 175rpx;background-color: #EEEEEE;">
						<view v-if="!xImage" style="color: #737373;">
							<view style="height: 50rpx;"></view>
							<view class="mar" style="width: 44rpx;height: 36rpx;">
								<image src="../../static/shangchuan.png" class="wh100"></image>
							</view>
							<view class="textCen foSi18 mar-top15">身份证国徽面</view>
						</view>
						<image v-if="xImage" :src="url+xImage" class="wh100 borRad20"></image>
					</view>
					<view class="mar-left30 borRad20" @click="shangImage(2)"
						style="width: 190rpx;height: 175rpx;background-color: #EEEEEE;">
						<view v-if="!scImage" style="color: #737373;">
							<view style="height: 50rpx;"></view>
							<view class="mar" style="width: 44rpx;height: 36rpx;">
								<image src="../../static/shangchuan.png" class="wh100"></image>
							</view>
							<view class="textCen foSi18 mar-top15">手持身份证</view>
						</view>
						<image v-if="scImage" :src="url+scImage" class="wh100 borRad20"></image>
					</view>
				</view>
			</view>
			<view class="wid100 xia mar-top30"></view>
			<view class="wid90 mar mar-top30">
				<view class="fowe600 foSi35 dis disAl">
					<span style="color: #FF0000;">*</span>
					<span>资格证书</span>
					<span class="foSi20 mar-left30" style="color: #737373;">图片大小不超过10M</span>
				</view>
				<view class="wid95 mar">
					<view class="borRad20 mar-top30" @click="shangImage(3)"
						style="width: 190rpx;height: 175rpx;background-color: #EEEEEE;">
						<view v-if="!statusImage" style="color: #737373;">
							<view style="height: 50rpx;"></view>
							<view class="mar" style="width: 44rpx;height: 36rpx;">
								<image src="../../static/shangchuan.png" class="wh100"></image>
							</view>
							<view class="textCen foSi18 mar-top15">上传图片</view>
						</view>
						<image v-if="statusImage" :src="url+statusImage" class="wh100 borRad20"></image>
					</view>
				</view>
			</view>
			<view class="wid100 xia mar-top30"></view>
			<view class="wid90 mar mar-top30">
				<view class="fowe600 foSi35 dis disAl">
					<span style="color: #FF0000;">*</span>
					<span>工作形象照</span>
					<span class="foSi20 mar-left30" style="color: #737373;">图片大小不超过10M</span>
				</view>
				<view class="wid95 mar">
					<view class="borRad20 mar-top30" @click="shangImage(4)"
						style="width: 190rpx;height: 175rpx;background-color: #EEEEEE;">
						<view v-if="!workImage" style="color: #737373;">
							<view style="height: 50rpx;"></view>
							<view class="mar" style="width: 44rpx;height: 36rpx;">
								<image src="../../static/shangchuan.png" class="wh100"></image>
							</view>
							<view class="textCen foSi18 mar-top15">上传图片</view>
						</view>
						<image v-if="workImage" :src="url+workImage" class="wh100 borRad20"></image>
					</view>
				</view>
			</view>
			<view class="wid100 xia mar-top30"></view>
			<view class="wid90 mar mar-top30">
				<view class="fowe600 foSi35 dis disAl">
					<span style="color: #FF0000;">*</span>
					<span>个人生活照</span>
					<span class="foSi20 mar-left30" style="color: #737373;">图片大小不超过10M</span>
				</view>
				<view class="wid95 mar dis disAl flwa">
					<block v-for="(item,index) in imageList1" :key="index">
						<view class="borRad20 mar-top30 poRel" :class="(index+1) % 3 != 0?'mar-right30':''"
							style="width: 190rpx;height: 175rpx;">
							<view @click="shanchu(index)" class="poAbs" style="right: 0;top: 0;z-index: 5;">
								<uni-icons type="closeempty" class="close" size="20"></uni-icons>
							</view>
							<image :src="url+item" class="wh100 borRad20"></image>
						</view>
					</block>
					<view v-if="imageList1.length < 9" class="borRad20 mar-top30" @click="shangImage(5)"
						style="width: 190rpx;height: 175rpx;background-color: #EEEEEE;color: #737373;">
						<view style="height: 50rpx;"></view>
						<view class="mar" style="width: 44rpx;height: 36rpx;">
							<image src="../../static/shangchuan.png" class="wh100"></image>
						</view>
						<view class="textCen foSi18 mar-top15">上传图片</view>
						<view class="textCen foSi18" style="margin-top: 6rpx;">{{imageList1.length}}/9</view>
					</view>
				</view>
			</view>
			<view class="wid100 xia mar-top30"></view>
			<view class="wid90 mar mar-top30">
				<view class="fowe600 foSi35 dis disAl">
					<span>个人视频介绍</span>
					<span class="foSi20 mar-left30" style="color: #737373;">图片大小不超过50M</span>
				</view>
				<view class="wid95 mar">
					<view v-if="!video" class="borRad20 mar-top30" @click="shangVideo"
						style="width: 190rpx;height: 175rpx;background-color: #F2F2F2;">
						<view style="height: 50rpx;"></view>
						<view class="mar" style="width: 72rpx;height: 59rpx;">
							<image src="../../static/shangchuan.png" class="wh100"></image>
						</view>
						<view class="foSi18 mar-top15 textCen" style="color: #737373;">上传视频</view>
					</view>
					<view v-if="video" class="borRad20 mar-top30 poRel"
						style="width: 190rpx;height: 175rpx;overflow: hidden;">
						<video :src="url+video" class="wh100"></video>
					</view>
				</view>
			</view>
			<view class="wid90 mar borRad40 dis disAl disJuC coFFF foSi35 hei86 mar-top40"
			 :style="'background-color: '+theme.main_color+';'" @click="sub_data">确认提交</view>
			<view style="height: 50rpx;"></view>
		</view>
		<view class="" v-else>
			<view class="" v-if="Object.keys(tech_info).length > 0 && zt">
				<view class="wid90 mar">
					<view class="hei20"></view>
					<view class="fowe800 foSi30 mar-top30">驳回理由</view>
					<view class="mar-top30 borRad10" style="background-color: #EEEEEE;padding: 30rpx;">{{bohui}}</view>
				</view>
				<view class="wid90 mar borRad40 dis disAl disJuC coFFF foSi35 hei86 mar-top40"
				 :style="'background-color: '+theme.main_color+';'" @click="zt = true">重新认证</view>
			</view>
			
		</view>
		<!-- 天地图使用示例 -->
		<zhuo-tianditu-select ref="tMap" :api-key="apiKey" :icon="icon" :search="false" @onSelect="addClick"></zhuo-tianditu-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				relevancyList: [],
				relevancyIndex: null,
				name: '',
				sax: 0,
				birthday: null,
				phone: '',
				work: '',
				provincial: '',
				visible: false,
				shopList: [],
				shopIndex: null,
				shop: null,
				address: null,
				introduction: '',
				zName: '',
				numberID: '',
				sImage: null,
				xImage: null,
				scImage: null,
				statusImage: null,
				workImage: null,
				imageList1: [],
				video: null,
				orderForm: '',
				beginTime: "00:00",
				finishTime: "23:59",
				xuan: 0,
				addressList: [],
				cityIndex: 0,
				// 当前选择的城市
				city: null,
				ads: null,
				id: null,
				tech_info: {}, // 技师详情
				zt: true,
				theme: null,
				apiKey: this.global.apiKey,
				icon: ''
			}
		},
		onLoad(option) {
			this.theme = uni.getStorageSync('theme')
			this.addressList = uni.getStorageSync('address');
			var that = this
			uni.getImageInfo({
				src: '../../static/dingwei3.png',
				success(res) {
					that.icon = res.path
				},
			})
		},
		onShow() {
			this.get_tech_info()
		},
		methods: {
			get_tech_info() {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/tech/tech_infos',
					method: 'POST',
					header: {
						'site-id': that.global.site_id,
						'token': uni.getStorageSync('token')
					},
					data: {
						tech_id: uni.getStorageSync('tech_id')
					},
					success(res) {
						let result = res.data
						console.log('请求详情')
						console.log(result)
						if (result.code == 1) {
							that.tech_info = result.data
							that.zt = true
							that.name = that.tech_info.name
							that.birthday = that.tech_info.birthday
							that.sax = that.tech_info.gender == 1?0:1
							that.phone = that.tech_info.phone
							for(var i=0; i<that.addressList.length; i++){
								if(that.addressList[i].id == that.tech_info.city){
									that.city = that.addressList[i]
								}
							}
							console.log(that.city)
							that.shop = null
							that.getShop(1)
							if(that.tech_info.auth_status == 2){
								that.id = that.tech_info.id
							}else if(that.tech_info.auth_status == 3){
								that.zt = false
								that.bohui = that.tech_info.auth_status_msg
							}
							if(that.tech_info.auth_status != 0){
								that.work = that.tech_info.work_years
								that.address = that.tech_info.address
								that.introduction = that.tech_info.brief
								that.zName = that.tech_info.real_name
								that.numberID = that.tech_info.idcard
								that.statusImage = that.tech_info.qua_img
								that.workImage = that.tech_info.work_img
								that.video = that.tech_info.brief_video
								that.sImage = that.tech_info.idcard_img[0]
								that.xImage = that.tech_info.idcard_img[1]
								that.scImage = that.tech_info.idcard_img[2]
								that.imageList1 = that.tech_info.life_img?that.tech_info.life_img:[]
							}
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
			addClick(value){
				var that = this
				console.log(value)
				that.address = value.address
				that.lat = value.location.lat;
				that.lon = value.location.lon;
			},
			xuandian() {
				var that = this;
				var that = this;
				var latitude = uni.getStorageSync('lat') ? uni.getStorageSync('lat') : 43.86414
				var longitude = uni.getStorageSync('lon') ? uni.getStorageSync('lon') : 125.35043
				// 打开地图
				that.$refs.tMap.open(longitude,latitude)
				// uni.chooseLocation({
				// 	success: function(res) {
				// 		console.log('位置名称：' + res.name);
				// 		console.log('详细地址：' + res.address);
				// 		console.log('纬度：' + res.latitude);
				// 		console.log('经度：' + res.longitude);
				// 		that.address = res.name
				// 		that.lat = res.latitude;
				// 		that.lon = res.longitude;
				// 	}
				// });
			},
			// 保存认证信息
			sub_data() {
				let that = this
				var idcard_img = []
				let rsg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				if (!rsg.test(that.numberID)){return uni.showToast({title: '请输入正确身份证号',icon: 'error',duration: 2000})};
				if (that.sImage == null || that.xImage == null || that.scImage == null) {
					return uni.showToast({
						title: '请上传身份证',
						icon: 'error'
					})
				} else {
					idcard_img.push(that.sImage)
					idcard_img.push(that.xImage)
					idcard_img.push(that.scImage)
				}
				if (!that.statusImage) {
					return uni.showToast({
						title: '请上传资格证书',
						icon: 'error'
					})
				}
				if (!that.workImage) {
					return uni.showToast({
						title: '请上传工作形象照',
						icon: 'error'
					})
				}
				if (!that.imageList1 || that.imageList1.length == 0) {
					return uni.showToast({
						title: '请上传个人生活照',
						icon: 'error'
					})
				}
				if (!that.zName) {
					return uni.showToast({
						title: '请输入真实姓名',
						icon: 'error'
					})
				}
				if (!that.name) {
					return uni.showToast({
						title: '请输入姓名',
						icon: 'error'
					})
				}
				let reg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
				if (!reg.test(that.phone)){return uni.showToast({title: '请输入正确手机号',icon: 'error',duration: 2000})};
				if (!that.work) {
					return uni.showToast({
						title: '请输入工作年份',
						icon: 'error'
					})
				}
				if (!that.shop.id) {
					return uni.showToast({
						title: '请选择挂靠门店',
						icon: 'error'
					})
				}
				console.log(that.city)
				let params = {
					tech_id: uni.getStorageSync('tech_id'),
					name: that.name,
					gender: that.sax == 0 ? 1 : 2,
					birthday: that.birthday,
					phone: that.phone,
					work_years: that.work,
					city: that.city.id,
					store_id: that.shop.id,
					address: that.address,
					brief: that.introduction,
					real_name: that.zName,
					idcard: that.numberID,
					idcard_img: idcard_img.join(','),
					qua_img: that.statusImage,
					work_img: that.workImage,
					life_img: that.imageList1.join(','),
					brief_video: that.video,
				}
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/tech/tech_authen',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息

					},
					data: params,
					success(res) {
						let result = res.data
						if (result.code == 1) {
							uni.showToast({
								title: '提交成功',
								icon: 'success'
							})
							setTimeout(() => {
								uni.navigateBack(1)
							}, 1000)
						} else {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							})
						}
					}
				})
				console.log(params)

			},
			// 获取定位所在城市
			getLocation() {
				var that = this
				if (!that.ads) {
					uni.getLocation({
						type: 'wgs84',
						success: async (res) => {
							that.lat = res.latitude
							that.lon = res.longitude
							//调用地址解析接口
							that.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/?location=', {
								key: 'MGJBZ-YHIKI-B4DGL-UPRDI-CIN7Z-UFB7H',
								location: res.latitude + ',' + res.longitude,
								output: 'jsonp'
							}).then(res => {
								console.log(res.result)
								that.ads = res.result.address
								that.address = res.result.address
							}).catch(err => {
								console.log(err);
							});

						}
					});
				} else {
					that.addressaddress = that.address
				}
			},
			getShop(pd) {
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/store/lists_city',
					method: "POST",
					header: {
						'site-id': that.global.site_id //自定义请求头信息
					},
					data: {
						city: that.city.id
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.shopList = result.data
							if(pd == 1){
								console.log('设置store')
								console.log(that.shopList)
								console.log(that.tech_info.store_id)
								for(var i=0; i<that.shopList.length; i++){
									console.log('门店id'+that.shopList[i].id)
									console.log('用户门店'+that.tech_info.store_id)
									if(that.shopList[i].id == that.tech_info.store_id){
										that.shop = that.shopList[i]
										that.shopIndex = i
										console.log('已经设置了storeID了，为啥不行呀')
									}
								}
							}
						} else {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							})
						}
					}
				})
			},

			bindCityChange: function(e) {
				this.cityIndex = e.detail.value
				this.city = this.addressList[this.cityIndex]
				this.shop = null
				this.getShop()
			},
			beginTimeChange: function(e) {
				this.beginTime = e.detail.value
			},
			finishTimeChange: function(e) {
				this.finishTime = e.detail.value
			},
			shanchu(index) {
				console.log(index)
				this.imageList1.splice(index, 1);
			},
			//上传视频
			shangVideo() {
				var that = this
				// #ifdef APP
				var xiangce = 0;
				var xiangji = 0;
				const permission = 'android.permission.WRITE_EXTERNAL_STORAGE'; // 要检查的权限
				const android_camera = 'android.permission.CAMERA';
				plus.android.checkPermission(
				  permission,
				  granted => {
					  console.log(granted);
					if (granted.checkResult == '-1') {
					  console.log('相册未授权');
					  xiangce = 1;
					}
				  },
				  error => {
					console.error('Error checking permission:', error.message);
				  }
				);
				plus.android.checkPermission(
				  android_camera,
				  granted => {
					  console.log(granted);
					if (granted.checkResult == '-1') {
					  console.log('相机未授权');
					  xiangji = 1;
					}
				  },
				  error => {
					console.error('Error checking permission:', error.message);
				  }
				);
				setTimeout(function(){
					console.log(xiangce);
					console.log(xiangji);
					if(xiangce == 1 && xiangji == 1){
						uni.showModal({
							title: '提示',
							content: that.global.name+'对存储空间/照片/相机/摄像头权限申请说明：便于您使用该功能上传您的照片/图片/视频及用于更换头像、意见反馈、举报用户、保存相册、发布动态、下载与客服沟通等场景中读取和写入相册和文件内容。',
							success: function (res) {
								if (res.confirm) {
									that.picopsshow = true;
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							},
						})
					}else if(xiangce == 1 && xiangji == 0){
						uni.showModal({
							title: '提示',
							content: that.global.name+'对存储空间/照片/相机/摄像头权限申请说明：便于您使用该功能上传您的照片/图片/视频及用于更换头像、意见反馈、举报用户、保存相册、发布动态、下载与客服沟通等场景中读取和写入相册和文件内容。',
							success: function (res) {
								if (res.confirm) {
									that.picopsshow = true;
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							},
						})
					}else if(xiangce == 0 && xiangji == 1){
						uni.showModal({
							title: '提示',
							content: that.global.name+'对存储空间/照片/相机/摄像头权限申请说明：便于您使用该功能上传您的照片/图片/视频及用于更换头像、意见反馈、举报用户、保存相册、发布动态、下载与客服沟通等场景中读取和写入相册和文件内容。',
							success: function (res) {
								if (res.confirm) {
									that.picopsshow = true;
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							},
						})
					}else{
						that.picopsshow = true;
					}
				},100)
				// #endif
				uni.chooseVideo({
					count: 1, //选择多少个视频
					sourceType: ['album', 'camera'], //视频来源相册和相机都可以
					maxDuration: 60,
					camera: 'back', //默认摄像头是后置摄像头
					success: (res) => {
						console.log(res)
						that.video = res.tempFilePath;
						that.shangchuan2(res.tempFilePath, 6)
					},
				})
			},
			//上传图片
			shangImage(index) {
				var that = this
				var count = 9
				if (index == 0 || index == 1 || index == 2 || index == 3 || index == 4) {
					count = 1
				} else if (index == 5) {
					count = 9 - that.imageList1.length
				}
				// #ifdef APP
				var xiangce = 0;
				var xiangji = 0;
				const permission = 'android.permission.WRITE_EXTERNAL_STORAGE'; // 要检查的权限
				const android_camera = 'android.permission.CAMERA';
				plus.android.checkPermission(
				  permission,
				  granted => {
					  console.log(granted);
					if (granted.checkResult == '-1') {
					  console.log('相册未授权');
					  xiangce = 1;
					}
				  },
				  error => {
					console.error('Error checking permission:', error.message);
				  }
				);
				plus.android.checkPermission(
				  android_camera,
				  granted => {
					  console.log(granted);
					if (granted.checkResult == '-1') {
					  console.log('相机未授权');
					  xiangji = 1;
					}
				  },
				  error => {
					console.error('Error checking permission:', error.message);
				  }
				);
				setTimeout(function(){
					console.log(xiangce);
					console.log(xiangji);
					if(xiangce == 1 && xiangji == 1){
						uni.showModal({
							title: '提示',
							content: that.global.name+'对存储空间/照片/相机/摄像头权限申请说明：便于您使用该功能上传您的照片/图片/视频及用于更换头像、意见反馈、举报用户、保存相册、发布动态、下载与客服沟通等场景中读取和写入相册和文件内容。',
							success: function (res) {
								if (res.confirm) {
									that.picopsshow = true;
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							},
						})
					}else if(xiangce == 1 && xiangji == 0){
						uni.showModal({
							title: '提示',
							content: that.global.name+'对存储空间/照片/相机/摄像头权限申请说明：便于您使用该功能上传您的照片/图片/视频及用于更换头像、意见反馈、举报用户、保存相册、发布动态、下载与客服沟通等场景中读取和写入相册和文件内容。',
							success: function (res) {
								if (res.confirm) {
									that.picopsshow = true;
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							},
						})
					}else if(xiangce == 0 && xiangji == 1){
						uni.showModal({
							title: '提示',
							content: that.global.name+'对存储空间/照片/相机/摄像头权限申请说明：便于您使用该功能上传您的照片/图片/视频及用于更换头像、意见反馈、举报用户、保存相册、发布动态、下载与客服沟通等场景中读取和写入相册和文件内容。',
							success: function (res) {
								if (res.confirm) {
									that.picopsshow = true;
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							},
						})
					}else{
						that.picopsshow = true;
					}
				},100)
				// #endif
				uni.chooseImage({
					count: 1,
					success: (res) => {
						// 上传内容
						that.shangchuan2(res.tempFilePaths[0], index)

						// for (var i=0; i<res.tempFilePaths.length; i++) {
						// 	that.shangchuan(res.tempFilePaths[i])
						// }
					},
				})
			},
			shangchuan(tempFilePaths) {
				var that = this
				uni.uploadFile({
					url: that.global.url + 'api/qianyu_smfw/common/file_upload',
					header: {
						'site-id': that.global.site_id,
						"token": uni.getStorageSync('token'),
					}, //请求token	
					filePath: tempFilePaths,
					name: 'file',
					success: (res) => {
						var apiresult = JSON.parse(res.data)
						if (apiresult.code == 1) {
							console.log(apiresult.data);
							that.imageList = that.imageList.concat(apiresult.data);
						} else {
							uni.showToast({
								title: apiresult.msg,
								icon: 'error',
								duration: 2000
							})
						}
					},
					fail() {
						uni.showToast({
							title: "网络连接失败",
							icon: 'error',
							duration: 2000
						})
					}
				});
			},



			shangchuan2(tempFilePaths, index) {
				var that = this
				uni.uploadFile({
					url: that.global.url + 'api/qianyu_smfw/common/file_upload',
					header: {
						'site-id': that.global.site_id,
						"token": uni.getStorageSync('token'),
					}, //请求token	
					filePath: tempFilePaths,
					name: 'file',
					success: (res) => {
						var apiresult = JSON.parse(res.data)
						if (apiresult.code == 1) {
							let dataurl = apiresult.data
							if (index == 0) {
								that.sImage = dataurl;
							} else if (index == 1) {
								that.xImage = dataurl;
							} else if (index == 2) {
								that.scImage = dataurl;
							} else if (index == 3) {
								that.statusImage = dataurl;
							} else if (index == 4) {
								that.workImage = dataurl;
							} else if (index == 5) {
								console.log(that.imageList1)
								console.log(res.tempFilePaths)
								that.imageList1 = that.imageList1.concat(dataurl);
								console.log(that.imageList1)
							} else if (index == 6) {
								// 视频上传
								that.video = dataurl
								console.log(dataurl)
							}
							that.$forceUpdate()










							// return apiresult.data
							// console.log(apiresult.data);
							// that.imageList = that.imageList.concat(apiresult.data);
						} else {
							uni.showToast({
								title: apiresult.msg,
								icon: 'error',
								duration: 2000
							})
						}
					},
					fail() {
						uni.showToast({
							title: "网络连接失败",
							icon: 'error',
							duration: 2000
						})
					}
				});
			},





			shopChange: function(e) {
				if (this.shopList.length > 0) {
					this.shopIndex = e.detail.value
					this.shop = this.shopList[this.shopIndex]
					console.log(this.shop)
				}
			},
			relevancyChange: function(e) {
				if (this.relevancyList.length > 0) {
					this.relevancyIndex = e.detail.value
				}
			},
			birthdayChange: function(e) {
				this.birthday = e.detail.value
			},
			open() {
				this.visible = true
			},
			confirm(val) {
				console.log(val)
				this.visible = false
				this.provincial = val.name
				this.$forceUpdate()
			},
			cancel() {
				this.visible = false
				this.$forceUpdate()
				console.log(this.visible)
			},
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
	}

	.xia {
		height: 1rpx;
		background-color: #E5E5E5;
	}

	.hei97 {
		height: 97rpx;
	}
</style>